<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	    		xmlns:ui="http://java.sun.com/jsf/facelets"
	  			xmlns:h="http://java.sun.com/jsf/html"
	  			xmlns:f="http://java.sun.com/jsf/core"
	  			xmlns:sf="http://www.springframework.org/tags/faces"
				template="/WEB-INF/layouts/standard.xhtml">

<ui:define name="content">

<h:form id="hotels">
	<div class="section">
		<h2>Hotel Results</h2>
		<p>
			<sf:commandLink value="Change Search" action="changeSearch"/>
		</p>
		<ui:fragment id="searchResultsFragment">
			<div id="searchResults">
				<h:outputText id="noHotelsText" value="No Hotels Found" rendered="#{hotels.rowCount == 0}"/>
				<h:dataTable id="hotels" styleClass="summary" value="#{hotels}" var="h" rendered="#{hotels.rowCount > 0}">
					<h:column>
						<f:facet name="header">
							<!-- @TODO - Ajax won't work here until JSF RI fixes bug in UIData.invokeOnComponent - scheduled for 1.2_09 -->
							<sf:commandLink id="sortByNameLink" ajaxEnabled="false" action="sort" value="Name">
								<f:param name="sortBy" value="name" />
							</sf:commandLink>
						</f:facet>
						#{h.name}
					</h:column>
					<h:column>
						<f:facet name="header">Address</f:facet>
						#{h.address}
					</h:column>
					<h:column>
						<f:facet name="header">
							<!-- @TODO - Ajax won't work here until JSF RI fixes bug in UIData.invokeOnComponent - scheduled for 1.2_09 -->
							<sf:commandLink id="sortByCity" ajaxEnabled="false" action="sort" value="City, State" >
								<f:param name="sortBy" value="city" />
							</sf:commandLink>
						</f:facet>
						#{h.city}, #{h.state}, #{h.country}
					</h:column> 
					<h:column>
						<f:facet name="header">Zip</f:facet>
						#{h.zip}
					</h:column>
					<h:column>
						<f:facet name="header">Action</f:facet>
						<sf:commandLink id="viewHotelLink" value="View Hotel" action="select"/>
					</h:column>
				</h:dataTable>
				<div class="buttonGroup">
					<sf:commandLink id="previousPageLink" value="Previous results" action="previous" rendered="#{searchCriteria.page > 0}"/>
					<sf:commandLink id="nextPageLink" value="More Results" action="next" rendered="#{not empty hotels and hotels.rowCount == searchCriteria.pageSize}"/>
				</div>
			</div>
		</ui:fragment>
	</div>
</h:form>
</ui:define>
</ui:composition>